#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <unordered_set>
#include <queue>
#include <climits>

using namespace std;

class Solution
{
public:
    int minimumRefill(vector<int> &plants, int capacityA, int capacityB)
    {
        int i = 0;
        int j = plants.size() - 1;
        int ans = 0;
        int a = capacityA;
        int b = capacityB;
        while (i <= j)
        {
            if (i == j)
            {
                if (a >= b)
                {
                    if (a < plants[i])
                    {
                        ans++;
                        a = capacityA;
                        a -= plants[i];
                    }
                }
                else if (a < b)
                {
                    if (b < plants[i])
                    {
                        ans++;
                        b = capacityB;
                        b -= plants[i];
                    }
                }
            }
            else
            {
                if (a < plants[i])
                {
                    ans++;
                    a = capacityA;
                }
                a -= plants[i];
                if (b < plants[j])
                {
                    ans++;
                    b = capacityB;
                }
                b -= plants[j];
            }
            i++;
            j--;
        }
        return ans;
    }
};

int main()
{
    Solution s;

    return 0;
}